<!DOCTYPE html>
<html>
	<head>
	<title></title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="yes" name="apple-touch-fullscreen">
	<meta content="telephone=no,email=no" name="format-detection">
	<script type="text/javascript" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/photoNewBook/jisuan.js"></script>
	<link rel="stylesheet" href="../css/photoNewBook/appendaddress.css">
	</head>
	<body>
		<input type="hidden" class="dd" value="1" />
		<input type="hidden" name="code1" id="code1" value="" />
		<input type="hidden" name="code2" id="code2" value="" />
		<input type="hidden" name="code3" id="code3" value="" />
		<div class="mian">
			<div class="return">
				 <img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/index/fanhui_zuo.png" alt="" class="img_1" onclick="Return()"/>
				 <b>添加地址</b>
				 <div class="superinduce" >保存</div>
			</div>
			<div class="compile">
				<div class="consignee">
				  <input type="text" name="" id="" value="" placeholder="收货人" class="name"/>
				  <img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/my_bookshelf_icon_left_nor.png" alt="" />
				  <div></div>
				</div>
				<div class="consignee number">
				  <input type="text" name="" id="" value='' class="phone" placeholder="手机号码" onkeyup="value=value.replace(/[^\d]/g,'')"/>
				  <img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/my_bookshelf_icon_left_nor.png" alt="" />
				  <div></div>
				</div>
				<div class="consignee zone">
				 <a>所在地区</a>
				 <div class="zone_div"></div>
				  <img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/my_bookshelf_icon_left_nor.png" alt="" />
				  <div></div>
				</div>
				<div class="detailed">
					<textarea name="" rows="" cols="" class="detailed_text" placeholder="详细地址：精确到门牌号"></textarea>
					 <div></div>
				</div>
				<!--<div class="tacitly">
				 <a>设置为默认地址</a>
					<div class="checkbox">
						<div class="checkbox_div" data="0"></div>
					</div>
				</div>-->
			</div>
			<form class="form-inline">
						      <div data-toggle="distpicker">
						        <div class="form-group form-group1">
						          <label class="sr-only" for="province1">Province</label>
						          <select class="form-control form-control1" id="province1"></select>
						        </div>
						        <div class="form-group form-group2">
						          <label class="sr-only" for="city1">City</label>
						          <select class="form-control form-control2" id="city1"></select>
						        </div>
						        <div class="form-group form-group3">
						          <label class="sr-only" for="district1">District</label>
						          <select class="form-control form-control3" id="district1"></select>
						        </div>
						      </div>
						      <div class="tacitly_ok">确定</div>
					    </form>
					    	<!--返回上一页-->
<input type="hidden" name="" id="recurrence" value="0" />
	</body>
		<script src="http://www.jq22.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/distpicker.data.js"></script>
<script src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/distpicker.js"></script>
<script type="text/javascript" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/photoNewBook/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../js/photoNewBook/personal.js"></script>
<script type="text/javascript">
	window.onload=function(){
		var data=$('.dd').val();
//		console.log(data)
		if(data==1){
			$('.checkbox_div').addClass('checkbox_div1');
        $('.checkbox').addClass('checkbox1');
		}
	}
	$('.checkbox').click(function(){
		var data=$('.checkbox_div').attr('data');
		if(data==0){
			$('.dd').val(1);
       		$('.checkbox_div').addClass('checkbox_div1');
           $('.checkbox').addClass('checkbox1');
           $('.checkbox_div').attr('data',1);
		}else if(data==1){
			$('.dd').val(0);
			$('.checkbox_div').removeClass('checkbox_div1');
           $('.checkbox').removeClass('checkbox1');
           $('.checkbox_div').attr('data',0);
		}
		
	})
	$('.zone').click(function(){
		$('.form-inline').css('display','block');
	})
	$('.tacitly_ok').click(function(){
		$('.form-inline').css('display','none');
		var control1=$(".form-control1 option:selected").attr('value');
		var control2=$(".form-control2 option:selected").attr('value');
		var control3=$(".form-control3 option:selected").attr('value');
		var code1=$(".form-control1 option:selected").attr('data-code');
		var code2=$(".form-control2 option:selected").attr('data-code');
		var code3=$(".form-control3 option:selected").attr('data-code');
		var control=console.log(code1,code2,code3);
		$('#code1').val(code1);
		$('#code2').val(code2);
		$('#code3').val(code3);
		$('.zone_div').html('');
		$('.zone_div').append(control1,control2,control3);		
	})
	$('.superinduce').click(function(){
		
		var addressee=$('.name').val();
		var phone=$('.phone').val();
		var userId = sessionStorage.getItem("userId");
		var areaId1=$('#code1').val();
		var areaId2=$('#code2').val();
		var areaId3=$('#code3').val();
		var pretermit=$('.dd').val();
		var address=$('.detailed_text').val();
		if(addressee==''||phone==''|| areaId1==''|| areaId2==''||address==''){
			alert('信息不完整');
		}else{
			$.ajax({
							type:"POST",
							url:"http://www.youyiku-yishu.cn/WebApp/AppOrders/addAddress",
							data:{userId:userId,areaId1:areaId1,areaId2:areaId2,areaId3:areaId3,pretermit:pretermit,address:address,addressee:addressee,phone:phone},
						    dataType:"json",
							beforeSend: function (XMLHttpRequest) {
							XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
													       }
							}).then(data=>{
									console.log(data);
									location.href = 'buy.html';
					
				 })
		}		        
	})
</script>
</html>
